package iterator.v1;

public class LinkedList_ implements Collection_ {
    Node head = null;
    Node tail = null;
    int size = 0;

    @Override
    public void add(Object obj) {
        Node node = new Node();
        node.data = obj;
        node.next = null;
        if (head == null) {
            head = tail = node;
            ++size;
        } else {
            tail.next = node;
            tail = node;
            ++size;
        }
    }

    @Override
    public int size() {
        return size;
    }

    private class Node {
        Object data;
        Node next;
    }
}
